﻿using System;

namespace configstore.CSM.Dto
{
    using wuo;
    internal class ConfigStoreInput
    {
        [WuoProperty("method")]
        public string Method { get; set; } = string.Empty;

        [WuoProperty("param")]
        public IDictionary<string, string> Params { get; set; } = new Dictionary<string, string>();

        internal Guid GetID(string name)
        {
            if (Params.ContainsKey(name) && Guid.TryParse(Params[name], out var id)) return id;

            return Guid.Empty;
        }
        internal string GetText(string name)
        {
            if (Params.ContainsKey(name)) return Params[name];

            return string.Empty;
        }
        internal int GetNumber(string name)
        {
            if (Params.ContainsKey(name) && int.TryParse(Params[name], out int i)) return i;

            return 0;
        }
    }
}
